<template>
    <div style="width:100%;height:100%;">
        <Layout style="background:transparent;width:100%;height:100%;">
            <Header v-if="!toggleLogin" style="background:transparent;padding:0;">
                 <Menu mode="horizontal" :active-name="tindex" :theme="theme1" style="padding-left: 15px;" @on-select="linlTo">
                    <div style="float:left;">
                        <img src="../../images/logo.jpg" alt="" style="width:60px;vertical-align:middle;">
                        <span style="color: #fff;font-size: 20px;font-weight:bolder;vertical-align:middle;margin: 0 30px 0 5px;">华小二</span>    
                    </div>
                    <MenuItem name="/homeMenu">首页</MenuItem>
                    <MenuItem name="/orderMenu">订单</MenuItem>
                    <MenuItem name="/shopMenu">商品</MenuItem>
                    <MenuItem name="/storeMenu">营销</MenuItem>
                    <!-- <MenuItem name="/userMenu">用户</MenuItem> -->
                    <!-- <MenuItem name="/accountMenu">统计</MenuItem> -->
                    <MenuItem name="/setMenu">设置</MenuItem>
                    <div style="float:right;margin-top:7px;margin-left:15px;">
                        <span class="middle">
                            <router-link to="/homeMenu"><Icon type="home" color="#fff" size="25"/></router-link>
                        </span>
                        <span class="middle" style="cursor:pointer;" @click="modal1 = true">
                            <Icon type="power" color="#fff" size="25"/>
                        </span>
                    </div>
                    <div style="float:right;">
                        <div class="demo-avatar">
                            <Avatar icon="person" size="large" />
                            <span style="color:#fff;margin:0 25px;">{{ username }}</span>
                        </div>
                    </div>
                </Menu>
            </Header>
            <router-view></router-view>
        </Layout>
        <Modal v-model="modal1" title="退出登录" @on-ok="ok1" @on-cancel="cancel1">
            <p>确认退出登录吗?</p>
        </Modal>
    </div>
</template>
<script>
import {mapGetters, mapMutations, mapActions} from 'vuex';
export default {
  data() {
      return {
        modal1: false,
        theme1: 'dark',
        toggleLogin: false,
        username: ''
      }
  },
 computed: {
   ...mapGetters(["tindex"])
    },
  methods: {
    // 点击导航菜单跳转路由
    linlTo(name) {
        var that = this
        that.$router.push(name);
    },
    // 确认退出
    ok1() {
        this.$router.push({name:'login'})
        localStorage.removeItem("data")
        localStorage.removeItem("agentId")
        localStorage.removeItem("btnss")
        localStorage.removeItem("busId")
        localStorage.removeItem("busTime")
        localStorage.removeItem("businessPage")
        localStorage.removeItem("shopPage")
        localStorage.removeItem("shop_id")
        localStorage.removeItem("userName")
        localStorage.removeItem("shopStatus")
    },
    cancel1() {

    }
  },
  updated() {
      if(this.$route.name === 'login' || this.$route.name === 'error-404' || this.$route.name === 'error-500') {
          this.$data.toggleLogin = true
      }else{
          this.$data.toggleLogin = false
      }
  },
  created() {
      this.username = localStorage.getItem("userName");
  }
}
</script>
<style scoped lang="scss">
.martop {
    margin-top:60px;
}
.middle {
    margin: 0 13px;
}
// 顶部导航被选中颜色
.ivu-menu {
    >.ivu-menu-item-selected {
        color: #19BE6B;
    }
}
</style>
